class Solution
{
public:
    int distinctPrimeFactors(vector<int> &nums)
    {
        unordered_set<int> factors;
        for (int num : nums)
        {
            for (int i = 2; i <= num; ++i)
            {
                while (num % i == 0)
                {
                    num /= i;
                    factors.insert(i);
                }
            }
        }
        return factors.size();
    }
};